package cn.kgc.job;

import cn.kgc.service.SeckillService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description:
 * @author: 石浩杰
 * @date: 2023-01-09 09:40
 */
@Slf4j
@Component
public class SeckillSkuUpJob {

    @Resource
    private SeckillService seckillService;

    /**
     * 秒杀商品上架
     * @throws Exception
     */
    @XxlJob(value = "skuUpJob", init = "init", destroy = "destroy")
    public void skuUpJob() throws Exception {
        log.info("定时任务开始执行.....");
        seckillService.secKillSkuUp();
    }
    public void init(){
        log.info("init初始化开始.....");


    }
    public void destroy(){ // 任务销毁时，销毁 XxlJobHelper.log
        log.info("destroy");
        seckillService.getSkillSessionAndSku();//初始化秒杀商品

    }
}
